package com.itheima.dao;

import com.itheima.domain.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface BookDao {

    @Insert("insert into tbl_book (type,name,description) values(#{type},#{name},#{description})")
    public int save(Book book);

    @Update("update tbl_book set type = #{type}, name = #{name}, description = #{description} where id = #{id}")
    public int update(Book book);

    @Delete("delete from tbl_book where id = #{id}")
    public int delete(Integer id);

    @Select("select * from tbl_book where id = #{id}")
    public Book getById(Integer id);

    @Select("select * from tbl_book")
    public List<Book> getAll();

    //分页查询
    @Select("select * from tbl_book limit #{begin},#{size}")
    List<Book>getByPage(@Param("begin") int begin, @Param("size") int size);

    //查询总记录数
    @Select("select count(*) from tbl_book")
    int getTotalCount();

}
